package com.keba.lamp.online.config;


import cn.dev33.satoken.sign.SaSignManager;
import cn.dev33.satoken.sign.config.SaSignConfig;
import cn.dev33.satoken.sign.template.SaSignTemplate;
import com.keba.lamp.online.properties.OnlineFilingProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({OnlineFilingProperties.class})
@Slf4j
@RequiredArgsConstructor
public class OnlineFilingAutoConfiguration {
    private final OnlineFilingProperties onlineFilingProperties;

    @Bean
    public SaSignTemplate saSignTemplate() {
        SaSignConfig signConfig = new SaSignConfig().setSecretKey(onlineFilingProperties.getSecret());
        // 创建签名模板
        SaSignTemplate signTemplate = new SaSignTemplate(signConfig);
        SaSignManager.setSaSignTemplate(signTemplate);
        return signTemplate;
    }

}
